import React, { Component } from 'react';
import axios from 'axios';
import store from '@/store';
import List from './List';
import { NavLink } from 'react-router-dom';
 
class App extends Component {
	
  handleChange () {
	document.querySelector('.search-content').style.display = "none";
	let name = document.querySelector('.ss').value;
	axios.post('/admin/goodssearch',{goods_name:name})
	.then((data) => {
		store.dispatch({
			type: 'CHANGE_SEARCH_LIST',
			data: data.data.data
		})
	})
	
  }

  render() {
    return (
      	<div className="box">
      		<header className="search-header">
				<NavLink id="leftbtn" className="iconfont icon-left-copy" to = "/home"></NavLink>
      			<div className="ssk">
      				<i className="iconfont icon-icon-search"></i>
      				<input onChange={this.handleChange.bind(this)} type="text" className="ss" placeholder="时尚潮流风向看这里"/>
      			</div>
      		</header>
      		<div className="search-content">
      			<div className="sc-top">
				大家都在搜 :
				</div>
				<div className="sc-content">
					<span>裙子</span>
					<span>衬衫</span>
					<span>裤子</span>
					<span>秋季</span>
					<span>呢子</span>
					<span>冬季</span>
				</div>
      		</div>
			<List searchlist = { store.getState().search.searchlist }/>
      	</div>
    );
  }
}

export default App;
